//
//  YYXPanelView.m
//  33-严雅兴
//
//  Created by YanYanxing on 2017/2/23.
//  Copyright © 2017年 yanyaxing. All rights reserved.
//

#import "YYXPanelView.h"

@implementation YYXPanelView

- (void)drawRect:(CGRect)rect {
    
    //MARK:调用封装好的方法
    [self drawMyPanel:rect andRadius:100 andColor:[UIColor blackColor]];
    
    [self drawMyPanel:rect andRadius:70 andColor:[UIColor greenColor]];
}



//MARK:封装方法
-(void)drawMyPanel:(CGRect)myRect andRadius:(CGFloat)radius andColor:(UIColor *) color{
    
    //圆心
    CGPoint center = CGPointMake(myRect.size.width * 0.5, myRect.size.height * 0.5);
    
    //起始弧度
    CGFloat startAngle = -M_PI_2;
    //结束弧度
    CGFloat endAngle = self.value * (2 * M_PI) - M_PI_2;
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];
    //画扇形一定要记得再画一条线到圆心
    [path addLineToPoint:center];
    [color set];
    [path fill];
    
    

}



@end
